package com.lhh.videoservice.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lhh.springcommon.annotation.WebLog;
import com.lhh.springcommon.annotation.WithRequestId;
import com.lhh.springcommon.entity.Collect;
import com.lhh.springcommon.entity.Video;
import com.lhh.springcommon.entity.vo.VideoVO;
import com.lhh.springcommon.utils.PageQuery;
import com.lhh.springcommon.utils.Response;
import com.lhh.videoservice.service.SearchService;
import com.lhh.videoservice.service.VideoPlayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 视频搜索
 * @author 李厚航
 */
@RestController
@RequestMapping("/videoSearch")
public class VideoSearchController {

    private final SearchService searchService;

    @Autowired
    public VideoSearchController(SearchService searchService) {
        this.searchService = searchService;
    }

    /**
     * 根据用户token做推荐
     * @return
     */
    @PostMapping("/algorithm")
    @WithRequestId
    @WebLog
    public Response<Page<VideoVO>> algorithm(@RequestBody PageQuery<String> page){
        return Response.success(searchService.recommendVideoByUid(page));
    }


    /**
     * 搜索视频数量
     * @param video
     * @return
     */
    @PostMapping("/searchNum")
    @WithRequestId
    @WebLog
    public Response<Long> searchNum(@RequestBody Video video){
        return Response.success(searchService.queryVideoCountByKeyword(video));
    }

}
